<?php 
class GoodsSpecModel extends Model{
	public $table='attr_class';
	public function get($gtid,$data=null){
		$AttrModel=M('attr_class');
		$classData=$AttrModel->where(array('gtid'=>$gtid,'is_spec'=>1))->all();
			// p($classData);exit;
		
		foreach ($classData as $k => $v) {
			$function =$v['show_type'];
			if(method_exists($this, $function)){
				$field =M('attr_value')->where(array('acid'=>$v['acid']))->all();
				$classData[$k]['html']=$this->$function($field,$data);
			}
			
		}
		return $classData;
	}

	public function box($fields,$data){
		$html='<select name="spec[attr]['.$fields[0]['acid'].'][]">';
		foreach($fields as $field){
			$value=$field['avid'];
			$selected="";
			$html.="<option $selected value='{$value}|{$field['attr_value']}'>{$field['attr_value']}</option>";
		}	
		$html.="</select>";
		return $html; 
	}


}



 ?>
